package cn.nawang.ebeim.uc.util;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class CheckProcessRunCmd {
  public boolean checkPro(){
    int countPro = 0;//统计进程数
    String[] cmd = new String[] { "cmd.exe", "/C", "wmic process get name" };
    try {
     Process process = Runtime.getRuntime().exec(cmd);
       BufferedReader reader = new BufferedReader(new InputStreamReader(
         process.getInputStream()));
       String line = null;
       while ((line = reader.readLine()) != null) {
        //判断进程是否已经存在
        if(line.indexOf("ebeim32.exe")!=-1){
          countPro = countPro+1;
          if(countPro==2){//如果存在相同进程
            return true;
          }
        }
       }
     process.getOutputStream().close();
    } catch (Exception e) {
     e.printStackTrace();
    }
    return false;
  }
  public static void main(String[] args) {
    CheckProcessRunCmd checo =  new CheckProcessRunCmd();
    checo.checkPro();
  }
}